<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The HttpMessage class</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="httpinflatestream.update.html">HttpInflateStream::update</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="httpmessage.addheaders.html">HttpMessage::addHeaders</a></div>
 <div class="up"><a href="book.http.html">HTTP</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="class.httpmessage" class="reference">
 <h1 class="title">The <a href="class.httpmessage.html" class="classname">HttpMessage</a> class</h1>
 
 <div class="partintro"><p class="verinfo">(PECL pecl_http &gt;= 0.10.0)</p>
  <div class="section" id="httpmessage.synopsis">
   <h2 class="title">类摘要</h2>
   <div class="classsynopsis">
    <div class="ooclass"></div>
    <div class="classsynopsisinfo">
     <span class="ooclass"><strong class="classname">HttpMessage</strong></span>
     <span class="oointerface">implements 
      <span class="interfacename"><strong class="interfacename">Iterator</strong></span>
     </span>
     <span class="oointerface">, 
      <span class="interfacename"><a href="class.countable.html" class="interfacename">Countable</a></span>
     </span>
     <span class="oointerface">, 
      <span class="interfacename"><strong class="interfacename">Serializable</strong></span>
     </span>
     {</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">void</span><span class="methodname"><a href="httpmessage.addheaders.html" class="methodname">addHeaders</a></span>
    ( <span class="methodparam"><span class="type">array</span> <code class="parameter">$headers</code></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$append</code><span class="initializer"> = false</span></span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="methodname"><a href="httpmessage.construct.html" class="methodname">__construct</a></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$message</code></span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">HttpMessage</span><span class="methodname"><a href="httpmessage.detach.html" class="methodname">detach</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">static public</span>
   <span class="type">HttpMessage</span><span class="methodname"><a href="httpmessage.factory.html" class="methodname">factory</a></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$raw_message</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$class_name</code><span class="initializer"> = &quot;HttpMessage&quot;</span></span>
  ]] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">static public</span>
   <span class="type">HttpMessage</span><span class="methodname"><a href="httpmessage.fromenv.html" class="methodname">fromEnv</a></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$message_type</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$class_name</code><span class="initializer"> = &quot;HttpMessage&quot;</span></span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">static public</span>
   <span class="type">HttpMessage</span><span class="methodname"><a href="httpmessage.fromstring.html" class="methodname">fromString</a></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$raw_message</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$class_name</code><span class="initializer"> = &quot;HttpMessage&quot;</span></span>
  ]] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">string</span><span class="methodname"><a href="httpmessage.getbody.html" class="methodname">getBody</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">string</span><span class="methodname"><a href="httpmessage.getheader.html" class="methodname">getHeader</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$header</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">array</span><span class="methodname"><a href="httpmessage.getheaders.html" class="methodname">getHeaders</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">string</span><span class="methodname"><a href="httpmessage.gethttpversion.html" class="methodname">getHttpVersion</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">HttpMessage</span><span class="methodname"><a href="httpmessage.getparentmessage.html" class="methodname">getParentMessage</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">string</span><span class="methodname"><a href="httpmessage.getrequestmethod.html" class="methodname">getRequestMethod</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">string</span><span class="methodname"><a href="httpmessage.getrequesturl.html" class="methodname">getRequestUrl</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">int</span><span class="methodname"><a href="httpmessage.getresponsecode.html" class="methodname">getResponseCode</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">string</span><span class="methodname"><a href="httpmessage.getresponsestatus.html" class="methodname">getResponseStatus</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">int</span><span class="methodname"><a href="httpmessage.gettype.html" class="methodname">getType</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">string</span><span class="methodname"><a href="httpmessage.guesscontenttype.html" class="methodname">guessContentType</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$magic_file</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$magic_mode</code><span class="initializer"> = MAGIC_MIME</span></span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">void</span><span class="methodname"><a href="httpmessage.prepend.html" class="methodname">prepend</a></span>
    ( <span class="methodparam"><span class="type"><a href="class.httpmessage.html" class="type HttpMessage">HttpMessage</a></span> <code class="parameter">$message</code></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$top</code><span class="initializer"> = true</span></span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">HttpMessage</span><span class="methodname"><a href="httpmessage.reverse.html" class="methodname">reverse</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">bool</span><span class="methodname"><a href="httpmessage.send.html" class="methodname">send</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">void</span><span class="methodname"><a href="httpmessage.setbody.html" class="methodname">setBody</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$body</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">void</span><span class="methodname"><a href="httpmessage.setheaders.html" class="methodname">setHeaders</a></span>
    ( <span class="methodparam"><span class="type">array</span> <code class="parameter">$headers</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">bool</span><span class="methodname"><a href="httpmessage.sethttpversion.html" class="methodname">setHttpVersion</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$version</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">bool</span><span class="methodname"><a href="httpmessage.setrequestmethod.html" class="methodname">setRequestMethod</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$method</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">bool</span><span class="methodname"><a href="httpmessage.setrequesturl.html" class="methodname">setRequestUrl</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$url</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">bool</span><span class="methodname"><a href="httpmessage.setresponsecode.html" class="methodname">setResponseCode</a></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$code</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">bool</span><span class="methodname"><a href="httpmessage.setresponsestatus.html" class="methodname">setResponseStatus</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$status</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">void</span><span class="methodname"><a href="httpmessage.settype.html" class="methodname">setType</a></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$type</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">HttpRequest|HttpResponse</span><span class="methodname"><a href="httpmessage.tomessagetypeobject.html" class="methodname">toMessageTypeObject</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">string</span><span class="methodname"><a href="httpmessage.tostring.html" class="methodname">toString</a></span>
    ([ <span class="methodparam"><span class="type">bool</span> <code class="parameter">$include_parent</code><span class="initializer"> = false</span></span>
  ] )</div>

   }</div>
  </div>

 <div class="section" id="http.httpmessage.members">
  <h2 class="title">Class Members</h2>
  <div class="section" id="http.httpmessage.properties">
   <h2 class="title">属性</h2>
   <table id="http.httpmessage.properties.instance" class="doctable table">
    <caption><strong>Instance Properties</strong></caption>
    
     <thead>
      <tr>
       <th>Modifiers</th>
       <th>Type</th>
       <th>Name</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>protected</td>
       <td>int</td>
       <td>type</td>
       <td>message type</td>
      </tr>

      <tr>
       <td>protected</td>
       <td>string</td>
       <td>body</td>
       <td>message body</td>
      </tr>

      <tr>
       <td>protected</td>
       <td>float</td>
       <td>httpVersion</td>
       <td>HTTP protocol version</td>
      </tr>

      <tr>
       <td>protected</td>
       <td>array</td>
       <td>headers</td>
       <td>message headers</td>
      </tr>

      <tr>
       <td>protected</td>
       <td>string</td>
       <td>requestMethod</td>
       <td>request method name</td>
      </tr>

      <tr>
       <td>protected</td>
       <td>requestUrl</td>
       <td>string</td>
       <td>request URL</td>
      </tr>

      <tr>
       <td>protected</td>
       <td>int</td>
       <td>responseCode</td>
       <td>response code</td>
      </tr>

      <tr>
       <td>protected</td>
       <td>string</td>
       <td>responseStatus</td>
       <td>response status message</td>
      </tr>

      <tr>
       <td>protected</td>
       <td>HttpMessage</td>
       <td>parentMessage</td>
       <td>reference to parent message</td>
      </tr>

     </tbody>
    
   </table>

   <blockquote class="note"><p><strong class="note">Note</strong>: 
    <p class="para">
     None of these default properties can be accessed by reference, array key/index notation nor be used
     in increment or decrement operations.
    </p>
   </p></blockquote>
  </div>
  <div class="section" id="http.httpmessage.constants">
   <h2 class="title">预定义常量</h2>
   <table class="doctable table">
    
    
     <thead>
      <tr>
       <th>Type</th>
       <th>Name</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>int</td>
       <td>TYPE_NONE</td>
       <td>message has is of no specific type</td>
      </tr>

      <tr>
       <td>int</td>
       <td>TYPE_REQUEST</td>
       <td>message is a request style HTTP message</td>
      </tr>

      <tr>
       <td>int</td>
       <td>TYPE_RESPONSE</td>
       <td>message is a response style HTTP message</td>
      </tr>

     </tbody>
    
   </table>

  </div>
 </div>
 </div>

 


















































































































































































































<h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="httpmessage.addheaders.html">HttpMessage::addHeaders</a> — Add headers</li><li><a href="httpmessage.construct.html">HttpMessage::__construct</a> — HttpMessage constructor</li><li><a href="httpmessage.detach.html">HttpMessage::detach</a> — Detach HttpMessage</li><li><a href="httpmessage.factory.html">HttpMessage::factory</a> — Create HttpMessage from string</li><li><a href="httpmessage.fromenv.html">HttpMessage::fromEnv</a> — Create HttpMessage from environment</li><li><a href="httpmessage.fromstring.html">HttpMessage::fromString</a> — Create HttpMessage from string</li><li><a href="httpmessage.getbody.html">HttpMessage::getBody</a> — Get message body</li><li><a href="httpmessage.getheader.html">HttpMessage::getHeader</a> — Get header</li><li><a href="httpmessage.getheaders.html">HttpMessage::getHeaders</a> — Get message headers</li><li><a href="httpmessage.gethttpversion.html">HttpMessage::getHttpVersion</a> — Get HTTP version</li><li><a href="httpmessage.getparentmessage.html">HttpMessage::getParentMessage</a> — Get parent message</li><li><a href="httpmessage.getrequestmethod.html">HttpMessage::getRequestMethod</a> — Get request method</li><li><a href="httpmessage.getrequesturl.html">HttpMessage::getRequestUrl</a> — Get request URL</li><li><a href="httpmessage.getresponsecode.html">HttpMessage::getResponseCode</a> — Get response code</li><li><a href="httpmessage.getresponsestatus.html">HttpMessage::getResponseStatus</a> — Get response status</li><li><a href="httpmessage.gettype.html">HttpMessage::getType</a> — Get message type</li><li><a href="httpmessage.guesscontenttype.html">HttpMessage::guessContentType</a> — Guess content type</li><li><a href="httpmessage.prepend.html">HttpMessage::prepend</a> — Prepend message(s)</li><li><a href="httpmessage.reverse.html">HttpMessage::reverse</a> — Reverse message chain</li><li><a href="httpmessage.send.html">HttpMessage::send</a> — Send message</li><li><a href="httpmessage.setbody.html">HttpMessage::setBody</a> — Set message body</li><li><a href="httpmessage.setheaders.html">HttpMessage::setHeaders</a> — Set headers</li><li><a href="httpmessage.sethttpversion.html">HttpMessage::setHttpVersion</a> — Set HTTP version</li><li><a href="httpmessage.setrequestmethod.html">HttpMessage::setRequestMethod</a> — Set request method</li><li><a href="httpmessage.setrequesturl.html">HttpMessage::setRequestUrl</a> — Set request URL</li><li><a href="httpmessage.setresponsecode.html">HttpMessage::setResponseCode</a> — Set response code</li><li><a href="httpmessage.setresponsestatus.html">HttpMessage::setResponseStatus</a> — Set response status</li><li><a href="httpmessage.settype.html">HttpMessage::setType</a> — Set message type</li><li><a href="httpmessage.tomessagetypeobject.html">HttpMessage::toMessageTypeObject</a> — Create HTTP object regarding message type</li><li><a href="httpmessage.tostring.html">HttpMessage::toString</a> — Get string representation</li></ul>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="httpinflatestream.update.html">HttpInflateStream::update</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="httpmessage.addheaders.html">HttpMessage::addHeaders</a></div>
 <div class="up"><a href="book.http.html">HTTP</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
